package org.jivesoftware.smack;

import java.io.InputStream;
import java.io.PrintStream;
import java.net.URL;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Enumeration;
import java.util.Iterator;
import java.util.List;
import java.util.Vector;
import org.jivesoftware.smack.parsing.ExceptionThrowingCallback;
import org.jivesoftware.smack.parsing.ParsingExceptionCallback;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserFactory;

public final class SmackConfiguration
{
  private static final String SMACK_VERSION = "3.3.1";
  private static int packetReplyTimeout = 10000;
  private static Vector<String> defaultMechs = new Vector();
  private static boolean localSocks5ProxyEnabled = true;
  private static int localSocks5ProxyPort = 7777;
  private static int packetCollectorSize = 5000;
  private static int defaultPingInterval = 1800;
  private static ParsingExceptionCallback defaultCallback = new ExceptionThrowingCallback();
  private static boolean autoEnableEntityCaps = true;

  static
  {
    try
    {
      ClassLoader[] arrayOfClassLoader1 = getClassLoaders();
      ClassLoader[] arrayOfClassLoader2 = arrayOfClassLoader1;
      int j = arrayOfClassLoader1.length;
      for (int i = 0; i < j; i++)
      {
        ClassLoader localClassLoader = arrayOfClassLoader2[i];
        Enumeration localEnumeration = localClassLoader.getResources("META-INF/smack-config.xml");
        while (localEnumeration.hasMoreElements())
        {
          URL localURL = (URL)localEnumeration.nextElement();
          InputStream localInputStream = null;
          try
          {
            localInputStream = localURL.openStream();
            XmlPullParser localXmlPullParser = XmlPullParserFactory.newInstance().newPullParser();
            localXmlPullParser.setFeature("http://xmlpull.org/v1/doc/features.html#process-namespaces", true);
            localXmlPullParser.setInput(localInputStream, "UTF-8");
            int k = localXmlPullParser.getEventType();
            do
            {
              if (k == 2)
                if (localXmlPullParser.getName().equals("className"))
                  parseClassToLoad(localXmlPullParser);
                else if (localXmlPullParser.getName().equals("packetReplyTimeout"))
                  packetReplyTimeout = parseIntProperty(localXmlPullParser, packetReplyTimeout);
                else if (localXmlPullParser.getName().equals("mechName"))
                  defaultMechs.add(localXmlPullParser.nextText());
                else if (localXmlPullParser.getName().equals("localSocks5ProxyEnabled"))
                  localSocks5ProxyEnabled = Boolean.parseBoolean(localXmlPullParser.nextText());
                else if (localXmlPullParser.getName().equals("localSocks5ProxyPort"))
                  localSocks5ProxyPort = parseIntProperty(localXmlPullParser, localSocks5ProxyPort);
                else if (localXmlPullParser.getName().equals("packetCollectorSize"))
                  packetCollectorSize = parseIntProperty(localXmlPullParser, packetCollectorSize);
                else if (localXmlPullParser.getName().equals("defaultPingInterval"))
                  defaultPingInterval = parseIntProperty(localXmlPullParser, defaultPingInterval);
                else if (localXmlPullParser.getName().equals("autoEnableEntityCaps"))
                  autoEnableEntityCaps = Boolean.parseBoolean(localXmlPullParser.nextText());
              k = localXmlPullParser.next();
            }
            while (k != 1);
          }
          catch (Exception localException2)
          {
            localException2.printStackTrace();
            try
            {
              localInputStream.close();
            }
            catch (Exception localException3)
            {
            }
          }
          finally
          {
            try
            {
              localInputStream.close();
            }
            catch (Exception localException4)
            {
            }
          }
        }
      }
    }
    catch (Exception localException1)
    {
      localException1.printStackTrace();
    }
  }

  public static String getVersion()
  {
    return "3.3.1";
  }

  public static int getPacketReplyTimeout()
  {
    if (packetReplyTimeout <= 0)
      packetReplyTimeout = 10000;
    return packetReplyTimeout;
  }

  public static void setPacketReplyTimeout(int paramInt)
  {
    if (paramInt <= 0)
      throw new IllegalArgumentException();
    packetReplyTimeout = paramInt;
  }

  public static int getPacketCollectorSize()
  {
    return packetCollectorSize;
  }

  public static void setPacketCollectorSize(int paramInt)
  {
    packetCollectorSize = paramInt;
  }

  public static void addSaslMech(String paramString)
  {
    if (!defaultMechs.contains(paramString))
      defaultMechs.add(paramString);
  }

  public static void addSaslMechs(Collection<String> paramCollection)
  {
    Iterator localIterator = paramCollection.iterator();
    while (localIterator.hasNext())
    {
      String str = (String)localIterator.next();
      addSaslMech(str);
    }
  }

  public static void removeSaslMech(String paramString)
  {
    if (defaultMechs.contains(paramString))
      defaultMechs.remove(paramString);
  }

  public static void removeSaslMechs(Collection<String> paramCollection)
  {
    Iterator localIterator = paramCollection.iterator();
    while (localIterator.hasNext())
    {
      String str = (String)localIterator.next();
      removeSaslMech(str);
    }
  }

  public static List<String> getSaslMechs()
  {
    return defaultMechs;
  }

  public static boolean isLocalSocks5ProxyEnabled()
  {
    return localSocks5ProxyEnabled;
  }

  public static void setLocalSocks5ProxyEnabled(boolean paramBoolean)
  {
    localSocks5ProxyEnabled = paramBoolean;
  }

  public static int getLocalSocks5ProxyPort()
  {
    return localSocks5ProxyPort;
  }

  public static void setLocalSocks5ProxyPort(int paramInt)
  {
    localSocks5ProxyPort = paramInt;
  }

  public static int getDefaultPingInterval()
  {
    return defaultPingInterval;
  }

  public static void setDefaultPingInterval(int paramInt)
  {
    defaultPingInterval = paramInt;
  }

  public static boolean autoEnableEntityCaps()
  {
    return autoEnableEntityCaps;
  }

  public static void setAutoEnableEntityCaps(boolean paramBoolean)
  {
    autoEnableEntityCaps = paramBoolean;
  }

  public static void setDefaultParsingExceptionCallback(ParsingExceptionCallback paramParsingExceptionCallback)
  {
    defaultCallback = paramParsingExceptionCallback;
  }

  public static ParsingExceptionCallback getDefaultParsingExceptionCallback()
  {
    return defaultCallback;
  }

  private static void parseClassToLoad(XmlPullParser paramXmlPullParser)
    throws Exception
  {
    String str = paramXmlPullParser.nextText();
    try
    {
      Class.forName(str);
    }
    catch (ClassNotFoundException localClassNotFoundException)
    {
      System.err.println("Error! A startup class specified in smack-config.xml could not be loaded: " + str);
    }
  }

  private static int parseIntProperty(XmlPullParser paramXmlPullParser, int paramInt)
    throws Exception
  {
    try
    {
      return Integer.parseInt(paramXmlPullParser.nextText());
    }
    catch (NumberFormatException localNumberFormatException)
    {
      localNumberFormatException.printStackTrace();
    }
    return paramInt;
  }

  private static ClassLoader[] getClassLoaders()
  {
    ClassLoader[] arrayOfClassLoader1 = new ClassLoader[2];
    arrayOfClassLoader1[0] = SmackConfiguration.class.getClassLoader();
    arrayOfClassLoader1[1] = Thread.currentThread().getContextClassLoader();
    ArrayList localArrayList = new ArrayList();
    ClassLoader[] arrayOfClassLoader2 = arrayOfClassLoader1;
    int j = arrayOfClassLoader1.length;
    for (int i = 0; i < j; i++)
    {
      ClassLoader localClassLoader = arrayOfClassLoader2[i];
      if (localClassLoader != null)
        localArrayList.add(localClassLoader);
    }
    return (ClassLoader[])localArrayList.toArray(new ClassLoader[localArrayList.size()]);
  }
}

/* Location:           D:\hygieia\userclient\common\libs\easemobchat_2.1.8.jar
 * Qualified Name:     org.jivesoftware.smack.SmackConfiguration
 * JD-Core Version:    0.6.1
 */